package com.billjc.activity.util;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class PropertiesUtil {
private static final Map<String, Properties> prosMap = new HashMap<String, Properties>();
	
	private synchronized static Properties loadProperties(String fileName) throws Exception {
		Properties pro=new Properties();
		InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
		pro.load(is);
		prosMap.put(fileName, pro);
		
		return pro;
	}
	
	public static String read(String fileName,String key) throws Exception {
		Properties pro = prosMap.get(fileName);
		if (pro == null) {
			pro = loadProperties(fileName);
		}
		
		return pro.getProperty(key);
	}
	public static void main(String[] args) throws Exception {
		System.out.println(read("config/appType.properties", "T331"));
	}
}
